package t5750.springbootnacos.controller;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;

@Controller
@RequestMapping("/discovery")
public class DiscoveryController {
	@NacosInjected
	private NamingService namingService;

	@RequestMapping(value = "/get", method = GET)
	@ResponseBody
	public List<Instance> get(@RequestParam String serviceName)
			throws NacosException {
		return namingService.getAllInstances(serviceName);
	}
}
